// Functions associated with the Toolbar class
//-----------------

//-----------------
// Includes libraries and other files
#include "Toolbar.h"
//-----------------

//-----------------
//// CONSTRUCTOR - Toolbar
Toolbar::Toolbar()
	: x_( 0), y_( 0), width_( 0), height_( 0)
{}

//// DESTRUCTOR - ~Toolbar
Toolbar::~Toolbar() {}
//-----------------

//-----------------
//// FUNCTION - mouseover
// return true if the mouse is currently over the toolbar
bool Toolbar::mouseover_toolbar( const int& x, const int& y) const {
	// Pre-conditions :- none
	assert( true);

	if(( x >= x_ && x <= x_+width_) && ( y >= y_ && y <= y_+height_))
		return true;
	else
		return false;
}

//// FUNCTION - get_x
// return the x position of the toolbar
float Toolbar::get_x() const {
	// Pre-conditions :- none
	assert( true);

	return x_;
}

//// FUNCTION - get_y
// return the y position of the toolbar
float Toolbar::get_y() const {
	// Pre-conditions :- none
	assert( true);

	return y_;
}

//// FUNCTION - get_width
// return the width of the toolbar
float Toolbar::get_width() const {
	// Pre-conditions :- none
	assert( true);

	return width_;
}

//// FUNCTION - get_height
// return the height of the toolbar
float Toolbar::get_height() const {
	// Pre-conditions :- none
	assert( true);

	return height_;
}

//// FUNCTION - set_x
// set the x position of the toolbar
void Toolbar::set_x( float x) {
	// Pre-conditions :- x must be positive
	assert( x >= 0);

	x_ = x;
}

//// FUNCTION - set_y
// set the y position of the toolbar
void Toolbar::set_y( float y) {
	// Pre-conditions :- y must be positive
	assert( y >= 0);

	y_ = y;
}

//// FUNCTION - set_width
// set the width of the toolbar
void Toolbar::set_width( float w) {
	// Pre-conditions :- w must be positive
	assert( w >= 0);

	width_ = w;
}

//// FUNCTION - set_height
// set the height of the toolbar
void Toolbar::set_height( float h) {
	// Pre-conditions :- h must be positive
	assert( h >= 0);

	height_ = h;
}

//// FUNCTION - setup_geometry
// create the Toolbar meshes
HRESULT Toolbar::setup_geometry( LPDIRECT3DDEVICE9 device) {
	// Pre-conditions :- the device must exist
	assert( device != nullptr);

	HRESULT hr;

	hr =	  orthographic_plane_.setup( device);
	hr = hr | D3DXCreateTextureFromFile( device, (PATH_ORTHOGRAPHIC+"texture_toolset_bg_dark.png").c_str(), &textures_[TEXTURE_BACKGROUND]);
	hr = hr | D3DXCreateTextureFromFile( device, (PATH_ORTHOGRAPHIC+"texture_toolset_bg_border.png").c_str(), &textures_[TEXTURE_BORDER]);
	hr = hr | D3DXCreateTextureFromFile( device, (PATH_ORTHOGRAPHIC+"texture_toolset_bg_corner.png").c_str(), &textures_[TEXTURE_CORNER]);

	return hr;
}